<!DOCTYPE html>
<html lang='en'>

<head>
    <meta charset='UTF-8'>
    <meta name='viewport' content='width=device-width, initial-scale=1.0'>
    <meta http-equiv='X-UA-Compatible' content='ie=edge'>
    <title>Document</title>
</head>

<body>
    <!-- 定义一个自定义指令, v-gettime, 使用当前指令的标签渲染出 多久之前  如果当前的时间戳减去之前的时间戳 < 10000, 返回'刚刚'  > 10000 '1小时' -->

    <div id='app'>
        <div v-gettime=""></div>
    </div>
    <script src='../js/vue.js'></script>

    <script>
        Vue.directive('gettime', {
            inserted(el, binding) {
                console.log(binding);
            }
        })

        const vm = new Vue({
            el: '#app',
            data: {
                time: 1599130665722
            },
            methods: {
                time: function () {

                }
            },
        })


        // 从你出生后到现在活了多少年
        // var nowDay = Date.now();
        // var birthday = +new Date('1993-07-22');
        // var time = nowDay - birthday;
        // var year = Math.floor(time / (1000 * 24 * 3600 * 365));
        // console.log(year);
    </script>
</body>

</html>